package me.zhengjie.modules.system.service.dto;

import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.Getter;
import lombok.Setter;

import java.io.Serializable;
import java.util.List;
import java.util.Objects;

/**
 * @Author: xin.peng
 * @Date: 2020/12/2
 * @Description :
 */
@Getter
@Setter
public class OrgDto implements Serializable {

    private String id;

    private String name;

    private String parentId;

    private Boolean un_use;

    @JsonInclude(JsonInclude.Include.NON_EMPTY)
    private List<OrgDto> children;

    private Boolean hasChildren = false;

    private Boolean leaf = true;

    public String getLabel() {
        return name;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        OrgDto orgDto = (OrgDto) o;
        return Objects.equals(id, orgDto.id) &&
                Objects.equals(name, orgDto.name);
    }

    @Override
    public int hashCode() {
        return Objects.hash(id, name);
    }
}
